<template>
  <lay-menu v-model:selected-key="selectedKey" v-model:open-keys="openKeys1" theme="dark" id="menus">
    <lay-sub-menu>
      <template #title>
        个人中心
      </template>
      <lay-menu-item><a href='/login'>个人账户</a></lay-menu-item>
      <lay-menu-item><a href='/reg'>修改密码</a></lay-menu-item>
    </lay-sub-menu>
    <lay-sub-menu>
      <template #title>
        自动化盯盘
      </template>
      <lay-menu-item><a href='/auto_select'>自选股设置</a></lay-menu-item>
      <lay-menu-item><a href='/auto_hold'>持仓股设置</a></lay-menu-item>
      <lay-menu-item><a href='#'>软件下载</a></lay-menu-item>
      <lay-menu-item><a href='#'>软件教程</a></lay-menu-item>
    </lay-sub-menu>
    <lay-sub-menu>
      <template #title>
        需求建议
      </template>
      <lay-menu-item><a href='/sugest_stock'>需求建议</a></lay-menu-item>
    </lay-sub-menu>
    <lay-sub-menu>
      <template #title>
        会员服务
      </template>
      <lay-menu-item><a href='/member_concact'>联系我们</a></lay-menu-item>
    </lay-sub-menu>
    <lay-sub-menu>
      <template #title>
        系统设置
      </template>
      <lay-menu-item><a href='/auto_common_table?xclass=news'>通用表格</a></lay-menu-item>
      <lay-menu-item><a href='/menu_set'>菜单设置</a></lay-menu-item>
      <lay-menu-item><a href='/role_list'>角色管理</a></lay-menu-item>
      <lay-menu-item><a href='/auto_common_table?xclass=sys_permission'>菜单表单编辑</a></lay-menu-item>
      <lay-menu-item><a href='/auto_common_table?xclass=users'>用户管理</a></lay-menu-item>
    </lay-sub-menu>
  </lay-menu>
</template>
<script>
import {onMounted, reactive, ref, toRefs} from 'vue'
import { getMenuList } from '../api/menu'
export default {
  setup() {
    const selectedKey = ref("5")
    const openKeys1 = ref(["7"])
    const state = reactive({
      content: ""
    })
    // 调取api获取数据
    const getNewsList = () => {
      const params = {
        page: 1,
        pageSize: 5
      }
      getMenuList(params).then(res => {
        state.content = res.data
      })
    }
    onMounted(getNewsList)
    // ...toRefs()将state里面得对象解构
    return {
      ...toRefs(state),
      selectedKey,
      openKeys1
    };
  },
};
</script>
